/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import Model.Client;
import Model.Commande;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

/**
 *
 * @author Anthares
 */
public class CommandeManager extends BaseManager {
    public CommandeManager(SessionFactory factory, String locale) {
        super(factory, locale);
    }

    public Commande createCommande(double amount, Client user) {
        Session sess = factory.openSession();
        sess.beginTransaction();
        Commande com = new Commande(new Date(), amount);
        com.setClientId(user);
        sess.save(com);
        
        sess.getTransaction().commit();
        sess.close();
        return com;
    }
}
